package com.moyun.finance.controller;

import com.moyun.finance.entity.Reimbursement;
import com.moyun.finance.entity.Response;
import com.moyun.finance.service.ReimbursementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/reimbursement")
public class ReimbursementController {
    @Autowired
    ReimbursementService rs;

    //报销单新增
    @RequestMapping("/save")
    public @ResponseBody Response save(@RequestBody Reimbursement reimbursement){
        Response res = rs.save(reimbursement);
        return res;
    }

    //报销单修改
    @RequestMapping("/update")
    public @ResponseBody Response update(@RequestBody Reimbursement reimbursement){
        Response res = rs.update(reimbursement);
        return res;
    }

    //报销单删除
    @RequestMapping("/delete")
    public @ResponseBody Response delete(@RequestBody Reimbursement reimbursement){
        Response res = rs.delete(reimbursement);
        return res;
    }

    //查询指定公司所有报销单信息
    @RequestMapping("/findAllByCompanyId")
    public @ResponseBody Response findAllByCompanyId(String companyId){
        List<Reimbursement> reimbursements = rs.findAll(companyId);
        return new Response("",reimbursements,true);
    }

    //根据id查报销单
    @RequestMapping("/findById")
    public @ResponseBody Response findOneById(String reimbursementId){
        Reimbursement r = rs.findOneById(reimbursementId);
        return new Response("",r,true);
    }

    //报销确认支付
    @RequestMapping("/confirm")
    public @ResponseBody Response confirm(@RequestBody Reimbursement reimbursement){
        Response r = rs.confirm(reimbursement);
        return r;
    }
}
